[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
overlay                  Declares a Subprogram as Belonging to an Overlay[TP]

 overlay procedure <pname>(<parameters>);
 overlay function  <fname>(<parameters>) : <ftype>;

    Turbo Pascal allows you to put a group of subprograms into an overlay
    file. Overlays allow the use of a specific memory region by many
    subprograms. Only one of those subprograms is in memory at any one
    time; thus space is conserved. When an overlay subprogram is called,
    the member of its group currently in memory is discarded, and that
    subprogram is loaded in from disk. Because of this, members of an
    overlay group should not call one another.

         <pname>    The procedure's name.

         <fname>    The function's name.

    <parameters>    An optional list of parameters. If no parameters are
                    declared, then the parentheses are dropped.

         <ftype>    The type of value that the function returns: Integer,
                    Real, Char, Boolean, enumerated, or a string-based
                    type.

    When the Turbo Pascal compiler encounters the subprogram Overlay
    declaration, then code generation is temporarily suspended for the
    main program and a file is created in which the overlay subprogram
    code is written. The name of the 'overlay file' will be the same name
    as the main program with an extension from '000' to '999'. Overlay
    subprograms that are declared contiguously with no other declarations
    between them will be grouped into the same overlay file. Overlay
    subprograms in the same group cannot call each other, since they share
    the same memory region and only one can be present at any time.

    Overlay subprograms may be nested.

    See the procedures OvrDrive and OvrPath in order to specify the
    location of the overlay files.

    Overlay subprograms cannot be recursive or FORWARD-declared.

  -------------------------------- Example ---------------------------------

           { This example will create two overlay files                }
           { The first overlay file, with extension .000, will consist }
           {of subprograms FirstChunk and NextChunk.                   }
           { The procedure MiddleMan will be part of the main program. }
           { The second overlay file, with extension .001 will consist }
           {of the subprogram LastChunk.                               }

           overlay procedure FirstChunk;
           begin
           end;

           overlay procedure NextChunk;
           begin
           end;

           procedure MiddleMan;
           begin
           end;

           overlay function  LastChunk : Boolean;
           begin
           end;

See Also: procedure function OvrDrive OvrPath
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson